package com.koron.css2.serviceManage.utils;

import com.koron.css2.serviceManage.bean.TServiceLog;
import com.koron.css2.serviceManage.service.ServiceLogService;
import com.mysql.cj.util.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.ADOConnection;

/**
 * 记录日志线程
 * 
 * @author Gaoyuan
 * @date 2018年7月12日
 *
 */
public class ServiceLogThread implements Runnable {

	private static final Logger logger = LogManager.getLogger(ServiceLogThread.class);

	/**
	 * 日志实体
	 */
	private TServiceLog log;

	private ServiceLogService logService;

	/**
	 * log4j日志内容
	 */
	private String desc;

	public ServiceLogThread() {
		super();
	}

	public ServiceLogThread(TServiceLog log, ServiceLogService logService, String desc) {
		super();
		this.log = log;
		this.logService = logService;
		this.desc = desc;
	}

	@Override
	public void run() {
		logger.info(desc);
		if(StringUtils.isNullOrEmpty(log.getWaterGroup())){
			log.setWaterGroup("运维平台");
		}
		ADOConnection.runTask(logService, "addLog", null, log);
	}

}
